import 'package:animal/network/api.dart';
import 'package:animal/ui/friend/NWApi.dart';
import 'package:animal/ui/friend/model/friend_model.dart';
import 'package:animal/widgets/PageStateWidget.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

class MyAzListViewController extends GetxController{
  State? state;
  MyAzListViewController({this.state});

  //列表状态
  var pageState = PageState.loading.obs;

  //好友列表
  var data = <FriendModel>[].obs;
  @override
  void onInit() {
    super.onInit();
    getFriendList();
  }

  ///获取好友列表
  void getFriendList(){
    HttpManager().get<List<FriendModel>>(ChatApi.chatFriendPage,queryParameters: {}).listen((value) {
      data.addAll(value.data!);
      pageState.value = data.isEmpty?PageState.empty:PageState.none;
    },onError: (err){
      pageState.value =  PageState.error;
      debugPrint(err.message);
    });
  }
}